#!/bin/bash
if test -z "$1"
then 
  echo 'Use: getPerf.sh <year>'
  exit 1
fi
year=$1
#for type in SCHOOL DISTRICT
for type in DISTRICT
do
  dir=perf$type
  if test ! -d $dir
  then mkdir $dir
  fi
  for grade in 03 04 05 06 07 08 10 HS
  do 
    for group in AL:AL FL:N FL:Y GE:01 GE:02 MG:Y RA1:01 RA1:02 RA1:03 RA1:04 RA1:06 RA1:15 RA1:20 SS:FLEP SS:LEP SS:LEPFLEP SS:SPED T1:0 T1:1
    do echo $type grade $grade $group
      curl http://profiles.doe.mass.edu/state_report/mcas.aspx?export_excel=yes\&reportType=$type\&grade=$grade\&apply2006=Y\&year=$year\&studentGroup=$group > $dir/$year$grade${group%:*}_${group#*:}.html 
      sleep 1
    done
  done
done
